package com.member.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.member.common.utils.DateUtils;
import com.member.shop.domain.SysBizRafflePrize;
import com.member.shop.mapper.SysBizRafflePrizeMapper;
import com.member.shop.service.ISysBizRafflePrizeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * 抽奖奖品Service业务层处理
 *
 * @author lxc
 * @date 2024-03-13
 */
@Service
public class SysBizRafflePrizeServiceImpl extends ServiceImpl<SysBizRafflePrizeMapper, SysBizRafflePrize> implements ISysBizRafflePrizeService {
    @Resource
    private SysBizRafflePrizeMapper sysBizRafflePrizeMapper;

    /**
     * 查询抽奖奖品
     *
     * @param prizeId 抽奖奖品主键
     * @return 抽奖奖品
     */
    @Override
    public SysBizRafflePrize selectSysBizRafflePrizeByPrizeId(Long prizeId) {
        return sysBizRafflePrizeMapper.selectById(prizeId);
    }

    /**
     * 查询抽奖奖品列表
     *
     * @param queryWrapper 抽奖奖品
     * @return 抽奖奖品
     */
    @Override
    public List<SysBizRafflePrize> selectSysBizRafflePrizeList(SysBizRafflePrize queryWrapper) {
        return sysBizRafflePrizeMapper.selectSysBizRafflePrizeList(queryWrapper);
    }

    /**
     * 新增抽奖奖品
     *
     * @param sysBizRafflePrize 抽奖奖品
     * @return 结果
     */
    @Override
    public int insertSysBizRafflePrize(SysBizRafflePrize sysBizRafflePrize) {
        sysBizRafflePrize.setCreateTime(DateUtils.getNowDate());
        return sysBizRafflePrizeMapper.insert(sysBizRafflePrize);
    }

    /**
     * 修改抽奖奖品
     *
     * @param sysBizRafflePrize 抽奖奖品
     * @return 结果
     */
    @Override
    public int updateSysBizRafflePrize(SysBizRafflePrize sysBizRafflePrize) {
        sysBizRafflePrize.setUpdateTime(DateUtils.getNowDate());
        return sysBizRafflePrizeMapper.updateById(sysBizRafflePrize);
    }

    /**
     * 批量删除抽奖奖品
     *
     * @param prizeIds 需要删除的抽奖奖品主键
     * @return 结果
     */
    @Override
    public int deleteSysBizRafflePrizeByPrizeIds(Long[] prizeIds) {
        return sysBizRafflePrizeMapper.deleteBatchIds(Arrays.asList(prizeIds));
    }

    /**
     * 删除抽奖奖品信息
     *
     * @param prizeId 抽奖奖品主键
     * @return 结果
     */
    @Override
    public int deleteSysBizRafflePrizeByPrizeId(Long prizeId) {
        SysBizRafflePrize sysBizRafflePrize = new SysBizRafflePrize();
        sysBizRafflePrize.setPrizeId(prizeId);
        sysBizRafflePrize.setDeleted(1);
        return sysBizRafflePrizeMapper.updateById(sysBizRafflePrize);
    }

    @Override
    public List<SysBizRafflePrize> selecIsPrizeList(Long[] filteredArray) {
        return sysBizRafflePrizeMapper.selecIsPrizeList(filteredArray);
    }
}
